#include "stdafx.h"

#include <Sum.h>
#include <Money.h>
#include <Bank.h>


namespace
{
	TEST( Sum, PlusMoney )
	{
		const ExpressionSp fiveBucks( Money::Dollar( 5 ) );
		const ExpressionSp tenFrancs( Money::Franc( 10 ) );
		Bank bank;
		bank.AddRate( _T("CHF"), _T("USD"), 2 );
		const auto sum( *(*fiveBucks + *tenFrancs) + *fiveBucks );
		const auto result( bank.Reduce( *sum, _T("USD") ) );
		EXPECT_EQ( *Money::Dollar( 15 ), *result );
	}

	TEST( Sum, Times )
	{
		const ExpressionSp fiveBucks( Money::Dollar( 5 ) );
		const ExpressionSp tenFrancs( Money::Franc( 10 ) );
		Bank bank;
		bank.AddRate( _T("CHF"), _T("USD"), 2 );
		const auto sum( *(*fiveBucks + *tenFrancs) * 2 );
		const auto result( bank.Reduce( *sum, _T("USD") ) );
		EXPECT_EQ( *Money::Dollar( 20 ), *result );
	}

} // unnamed namespace
